﻿@{
    ViewBag.Title = "成品库入库单据";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script>
    $(function () {
        initControl();
    });
    function initControl() {
        $('select').bindSelect();
        $("#txtFProCompanyNO").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=1",
            id: "UnitNO",
            text: "UnitNOShortName"
        });
        var currentDate = new Date();
        var keyValue = $.request("keyValue");

        //显示台账日期
        $.ajax({
            url: "/WareHouse/EnterWareHouse/GetInfoDocumentNum",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            success: function (data) {
                $("#form1").formSerialize(data);
                $("#txtBill").val(data);
                if (data == currentDate.format("yyyyMM")) {                 
                    gridList1();
                } else {
                    gridList2();
                }               
            }
        });
        //显示单据编号
        $.ajax({      
            url: "/WareHouse/EnterWareHouse/GetInfoDocumentNum2",
            data: { keyValue: keyValue },
            dataType: "text",
            async: false,
            success: function (data) {
                $("#txtBill").val(data);
            }
        });
        //来料单位
        $("#txtFHappenCompanyNO").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=1",
            id: "UnitNO",
            text: "UnitNOShortName",
        });
        //发生方式
        $("#txtFypeNoName").bindSelect({
            url: "/BaseData/BUS_SJ_Dictionary/GetGridJson?keyword=" + "CR",
            id: "UseUnit",
            text: "UnitTypeNoName",
        });

        var currentDate = new Date();
        $("#txtFBatchNo").val(currentDate.format("yyyy-MM-dd"));
        $("#txtCheckdate").val(currentDate.format("yyyy-MM-dd"));
        $("#txtInputdate").val(currentDate.format("yyyy-MM-dd"));
        $("#txtCheckUpdate").val(currentDate.format("yyyy-MM-dd"));  
    }
    function editText(item) {
        var node = item.parentNode;
        node.innerHTML = '<span onclick="btn_add();">...</span>';
    }
    function selectText(cellvalue, options, rowObject) {
        if (cellvalue == undefined) {
            cellvalue = " ";
        }
        return '<div  name="FDocuTypeName" onclick="editText(this);">' + cellvalue + '</div>';
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "请输入成品出库单据信息",
            url: "/WareHouse/EnterWareHouse/WareHouseOutInputAdd",
            width: "860px",
            height: "480px",
            callBack: function (iframeId) {
                var datarow = top.frames[iframeId].GetDataValue();
                var id = $('#gridList').jqGrid('getGridParam', 'selrow');
                $('#gridList').jqGrid("setRowData", id, datarow);
                $('#gridList').jqGrid("addRowData", id, {});
            }
        });
    }
    function btn_Return() {
        parent.$.detailClose();
    }
    function btn_Del() {
        $.deleteForm({
            url: "/VBaseData/V_CPK_45_HZ_StoCPKListAcco_Mid/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().FDocuNO },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function gridList1() {
        $("#grid111").show();
        $("#grid222").hide();
        var $gridList = $("#gridList1");
        $gridList.dataGrid({
            url: "/VBaseData/V_CPK_45_HZ_StoCPKListAcco_Mid/GetGridJson",
            height: $(window).height() - 250,
            colModel: [
                    { label: "id", name: "FRegisterID", width: 120, align: 'center', hidden: true },
                    { label: '单据编号', name: 'FDocuNO', width: 150, align: 'center' },
                    //{ label: '单据编号', name: 'FDouBarCode', width: 120, align: 'center' },
                    { label: '单据日期', name: 'FCurDate', width: 80, align: 'center' },

                    //{ label: "来料单位", name: "FProCompanyNO", width: 80, align: 'center' },
                    //{ label: "来料单位名称", name: "FProCompanyName", width: 120, align: 'left' },
                    { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left' },
                    { label: '零件名称', name: 'FProductionName', width: 140, align: 'left' },

                    { label: '开票数量', name: 'FQuantity_KP', width: 60, align: 'right' },
                    { label: '实际数量', name: 'FQuantity', width: 80, align: 'right' },
                    { label: '零件单价(元)', name: 'FPrice_Settle', width: 80, align: 'right' },
                    { label: '金额(元)', name: ' ', width: 60, align: 'right' },//FAmount_KP  UnitPriceAll
                    { label: '批次号', name: 'FBatchNo', width: 140, align: 'left' },


                    { label: '容器编号', name: 'FContainerNO', width: 80, align: 'right' },
                    { label: '容器名称', name: 'FContainerName', width: 80, align: 'left' },
                    { label: '容器数量', name: 'FContainerQuantity', width: 60, align: 'right' },
                    { label: '标准装箱数', name: 'FContent', width: 70, align: 'right' },
                    { label: '实际装箱数', name: 'FFactContent', width: 70, align: 'right' },

                    { label: '托盘编号', name: 'FPalletNO', width: 60, align: 'center' },
                    { label: '托盘数量', name: 'FPalletQuantity', width: 60, align: 'right' },
                    { label: '托盘标准容量', name: 'FPalletContent', width: 60, align: 'right' },
                    { label: '托盘实际容量', name: 'FPalletFactContent', width: 60, align: 'right' },

                    { label: '制造单位', name: 'FProCompanyNO', width: 80, align: 'left' },
                    { label: '制造单位名称', name: 'FProCompanyName', width: 90, align: 'left' },
                    { label: '零件分类编码', name: 'FProductionTypeNO', width: 90, align: 'center' },
                    { label: '零件分类名称', name: 'FProductionTypeName', width: 90, align: 'left' },
                    //{ label: '凭证编号', name: 'FCredence', width: 80, align: 'left' },

                    { label: '仓库编号', name: 'FStoreNO', width: 80, align: 'left' },
                    { label: '仓库名称', name: 'FStoreName', width: 80, align: 'center' },
                    { label: '定置编号', name: 'FStoreSetNO', width: 80, align: 'center' },

                    { label: '输入人员', name: 'FUpdateBy', width: 60, align: 'center' },
                    { label: '输入日期', name: 'FUpdateDate', width: 80, align: 'center' },
                    { label: '输入时间', name: 'FUpdateTime', width: 60, align: 'center' },

                    { label: '审核人', name: 'FAuditingBy', width: 80, align: 'center' },
                    { label: '审核日期', name: 'FAuditingDate', width: 80, align: 'center' },
                    { label: '审核时间', name: 'FAuditingTime', width: 60, align: 'center' },
            ],
            pager: "#gridPager1",
            sortname: 'F_DepartmentId asc,F_CreatorTime desc',
            viewrecords: true
        });
        $("#selectAll").click(function (e) {
            $("input[name='checkbox']").prop("checked", this.checked);
            e.stopPropagation();
        });
    }
    function gridList2() {
        $("#grid111").hide();
        $("#grid222").show();
        var $gridList = $("#gridList2");
        $gridList.dataGrid({
            url: "/VBaseData/V_CPK_48_HZ_StoCPKListAcco_Arc/GetGridJson",
            height: $(window).height() - 230,
            colModel: [
                    { label: "id", name: "FRegisterID", width: 120, align: 'center', hidden: true },
                    { label: '<input id="selectAll" type="checkbox" style="text-align:center;">', width: 60, align: 'center', sortable: false, formatter: $.checkbox, unformat: $.empty },
                    { label: '单据编号', name: 'UseUnit', width: 120, align: 'center' },
                    { label: '单据编号', name: 'FDouBarCode', width: 120, align: 'center' },
                    { label: '单据日期', name: 'FCurDate', width: 80, align: 'center' },

                    { label: "来料单位", name: "FProCompanyNO", width: 80, align: 'center' },
                    { label: "来料单位名称", name: "FProCompanyName", width: 120, align: 'center' },
                    { label: '零件编号', name: 'FProductionNO', width: 120, align: 'center' },
                    { label: '零件名称', name: 'FProductionName ', width: 140, align: 'center' },

                    { label: '开票数量', name: 'FQuantity_KP', width: 60, align: 'center' },

                    { label: '实际数量', name: 'FQuantity', width: 80, align: 'center' },
                    { label: '零件单价(元)', name: 'FPrice_KP', width: 80, align: 'center' },
                    { label: '金额(元)', name: 'FAmount_KP', width: 60, align: 'center' },
                    { label: '批次号', name: 'FBatchNo', width: 140, align: 'center' },

                    { label: '托盘编号', name: 'FMoney_Plane', width: 60, align: 'left' },
                    { label: '托盘数量', name: 'FProductionTypeNO', width: 60, align: 'left' },
                    { label: '实际容量', name: 'FContainerNO', width: 60, align: 'left' },
                    { label: '标准容量', name: 'FContainerQuantity', width: 60, align: 'left' },
                    { label: '容器编号', name: 'FContainerNO', width: 80, align: 'center' },
                    { label: '容器名称', name: 'FContainerName', width: 80, align: 'center' },
                    { label: '容器数量', name: 'FContainerQuantity', width: 60, align: 'center' },
                    { label: '标准装箱数', name: 'FContent', width: 60, align: 'center' },
                    { label: '实际装箱数', name: 'FFactContent', width: 60, align: 'center' },

                    { label: '开票总数', name: 'FQuantity_KP', width: 60, align: 'center' },
                    { label: '实际总数', name: 'FQuantity', width: 60, align: 'center' },
                    { label: '开票总价(元)', name: 'FAmount_KP', width: 80, align: 'center' },
                    { label: '实际总价(元)', name: 'FAmount', width: 80, align: 'center' },
                    { label: '凭证编号', name: 'FVoucherNo', width: 80, align: 'center' },

                    { label: '备注', name: 'FDescription', width: 80, align: 'center' },
                    { label: '供货单位', name: 'FProductionTypeNO', width: 80, align: 'center' },
                    { label: '供货单位名称', name: 'FProductionTypeName', width: 100, align: 'center' },
                    { label: '零件分类', name: 'FState', width: 60, align: 'center' },
                    { label: '仓库编号', name: '', width: 60, align: 'center' },

                    { label: '仓库名称', name: ' ', width: 80, align: 'center' },
                    { label: '定置编号', name: ' ', width: 60, align: 'center' },

                    { label: '输入人员', name: 'FUpdateBy', width: 60, align: 'center' },
                    { label: '输入日期', name: 'FUpdateDate', width: 60, align: 'center' },
                    { label: '输入时间', name: 'FUpdateTime', width: 60, align: 'center' },

                    { label: '审核人', name: 'FUpdateDate', width: 60, align: 'center' },
                    { label: '审核日期', name: 'FUpdateTime', width: 60, align: 'center' },
                    { label: '审核时间', name: 'FUpdateDate', width: 60, align: 'center' },
            ],
            pager: "#gridPager2",
            sortname: 'F_DepartmentId asc,F_CreatorTime desc',
            viewrecords: true,
        });
    }
</script>
<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-center">
        <form id="form1">
            <div>
                <table class="form" style="width:97%;text-align:left;margin:0px;margin-top:-20px;margin-bottom:-3px; border-bottom:2px solid #ccc;">
                    <tr>
                        <td style="width:97%; padding: 5px 10px;">
                            <div class="btn-group" style="margin-left:500px;margin-bottom:-10px;">
                                <h2 style="font-family:隶书;font-weight:bold;font-size:26px">入库单据</h2>
                            </div>
                            <div class="btn-group" style="margin-left:490px;margin-bottom:-25px;">
                                <a id="" class="btn btn-primary center-block " onclick="btn_Del()"><span class="glyphicon glyphicon-ok"></span> 打印</a>
                            </div>
                            <div class="btn-group" style="margin-left:30px;margin-bottom:-25px;">
                                <a id="" class="btn btn-primary center-block  " onclick="btn_Return()"><span class="glyphicon glyphicon-remove"></span> 返回</a>
                            </div>
                        </td>
                    </tr>
                </table>
                <table class="form" style="margin-top:10px;">
                    <tr>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:160px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:220px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">单据编号</th>
                        <td class="formValue" style="width:160px;height:20px;">
                            <input id="txtBill" type="text" class="form-control required" readonly="readonly" onfocus=this.blur() value="" />
                        </td>
                        <th class="formTitle" style="width:10px;">&nbsp;</th>
                        <td class="formValue" style="width:20px;">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle" style="width:100px;">来料单位</th>
                        <td class="formValue" style="width:160px;">
                            <select id="txtFHappenCompanyNO" name="F_DutyId" class="form-control" disabled="" onshow="2"></select>
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:80px;">单据日期</th>
                        <td class="formValue" style="width:120px;height:20px;">
                            <input id="txtFBatchNo" type="text" class="form-control required" readonly="readonly" onfocus=this.blur() value=""  />
                        </td>

                    </tr>
                    <tr>
                        <th class="formTitle" style="width:100px;">发生方式</th>
                        <td class="formValue" style="width:160px;">
                            <select id="txtFypeNoName" name="F_DutyId" class="form-control"onshow="1" disabled="">
       
                            </select>
                            @* <input id="txtFypeNoName" name="txtFypeNoName" type="text" class="form-control required" value="" />*@
                        </td>
                        <th class="formTitle" style="width:120px;">摘要说明</th>
                        <td class="formValue" style="width:160px;">
                            <input id="" type="text" class="form-control required" readonly="readonly" onfocus=this.blur() value="" />
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:100px;">&nbsp;</th>
                        <td class="formValue" style="width:120px;">
                            &nbsp;
                        </td>
                        <th class="formTitle" style="width:80px;">凭证编号</th>
                        <td class="formValue" style="width:120px;height:20px;">
                            <input id="" type="text" class="form-control required" readonly="readonly" onfocus=this.blur() value="" />
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <br />
        <div id="grid111">
            <table id="gridList1"></table>
        </div>
        <div id="grid222">
            <table id="gridList2"></table>
        </div>
        <div class="price-info">
            <table class="form" style="margin-left:60px;">
                <tr>
                    <th class="formTitle" style="width:20px;">送货员</th>
                    <td class="formValue">
                        <input type="text" class="form-control" style="width:80px;text-align:center" value="刘春华" />
                    </td>
                    <th class="formTitle" style="width:60px;">仓库保管员</th>
                    <td class="formValue">
                        <input type="text" class="form-control" style="width:80px;text-align:center" value="刘春华" />
                    </td>
                    <th class="formTitle">输入日期</th>
                    <td class="formValue">
                        <input type="text" id="txtInputdate" class="form-control " style="width:100px;text-align:center" value="2017-07-07" />
                    </td>
                    <th class="formTitle">审核日期</th>
                    <td class="formValue" style="padding-right: 20px;">  
                        <input type="text"id="txtCheckUpdate" class="form-control" style="width:100px;text-align:center" value="2017-07-07" />
                    </td>
                    <th class="formTitle">检查日期</th>
                    <td class="formValue">
                        <input type="text"id="txtCheckdate" class="form-control " style="width:100px;text-align:center" value="" />
                    </td>

                </tr>
            </table>
        </div>
    </div>
</div>







